<?php

namespace App\Models;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Laracasts\Presenter\PresentableTrait;

class Member extends Authenticatable
{
	use PresentableTrait, Notifiable;
	
	protected $table = 'mgt_members';

	protected $presenter = 'App\Http\Presenters\MemberPresenter';

	protected $guarded = array();

	public $timestamps = false;	

	const DEFAULT_PASSWORD = '123456';

	/* 会员状态 */
	const STATUS_NORMAL = 1;	//正常
	const STATUS_FREEZE = 0;	//冻结

	/* 会员类型 */
	const TYPE_USER 	= 1;	//普通用户
	const TYPE_ADMIN 	= 0; 	//管理员

	/* 应聘审核状态 */
	const RECRUIT_NONE		= 0;	//不处理
	const RECRUIT_NEW 		= 1;	//未审核
	const RECRUIT_APPROVE 	= 2;	//已审核
	const RECRUIT_DENY 		= 3;	//审核拒绝


	/**
	 * 重写默认密码字段
	 * @return [type] [description]
	 */
	public function getAuthPassword() 
	{
      return $this->passwd;
 	}


 	/**
 	 * 个人名下的人员
 	 * @return [type] [description]
 	 */
	public function children()
	{
		return $this->hasMany('App\Models\Member','parent_id','id');
	}

	public function number()
	{
		return $this->children()->count();
	}

	public function parent()
	{
		return $this->belongsTo('App\Models\Member','parent_id','id');
	}

}